package svc

import (
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
	"person/personapi/internal/config"
	"person/personapi/internal/middleware"
	"person/personrpc/personrpcclient"
)

type ServiceContext struct {
	Config              config.Config
	PersonRpc           personrpcclient.Personrpc
	UserTokenMiddleware rest.Middleware
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:              c,
		PersonRpc:           personrpcclient.NewPersonrpc(zrpc.MustNewClient(c.PersonRpc)),
		UserTokenMiddleware: middleware.NewUserTokenMiddleware().Handle,
	}
}
